<html>
<head><meta charset="utf-8"><title>metadata-target · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html">metadata-target</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220184047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220184047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220184047">(Dec 16 2020 at 22:43)</a>:</h4>
<p>Some context for <a href="https://github.com/rust-lang/cargo/pull/8987">https://github.com/rust-lang/cargo/pull/8987</a> -- internally we have a bunch of crates deny-listed since they use incompatible licenses and such. This causes issues when <code>metadata</code> pulls in dependencies for _all_, which includes things like <code>fuchia</code>, and thus increases the space of crates that _might_ have been deny-listed.</p>



<a name="220184129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220184129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220184129">(Dec 16 2020 at 22:44)</a>:</h4>
<p>Relatedly, it's quite unfortunate that <code>cargo metadata</code> uses a different convention for selecting targets than like every other cargo tool. Is there a particular reason for this? We can't really change the default now, but it has implications downstream such as <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6908">https://github.com/rust-analyzer/rust-analyzer/issues/6908</a></p>



<a name="220184765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220184765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220184765">(Dec 16 2020 at 22:49)</a>:</h4>
<p>Ouch, it looks like this hits <code>rustfmt</code> as well, which does not ever pass <code>--filter-platform</code> :/<br>
<a href="https://github.com/rust-lang/rustfmt/blob/39fe0e12ea7fefc50e4be346b9ea90c308587979/src/cargo-fmt/main.rs#L662">https://github.com/rust-lang/rustfmt/blob/39fe0e12ea7fefc50e4be346b9ea90c308587979/src/cargo-fmt/main.rs#L662</a></p>



<a name="220192840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220192840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220192840">(Dec 17 2020 at 00:25)</a>:</h4>
<p>The intention is that <code>cargo metadata</code> gives you a target-agnostic view of the dependency graph, similar to how <code>Cargo.lock</code> works</p>



<a name="220192908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220192908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220192908">(Dec 17 2020 at 00:26)</a>:</h4>
<p>this is a known thorn in Cargo though where projects often have only a small handful of targets they care about, so the <code>Cargo.lock</code> file is bigger than necessary (and transitively <code>cargo metadata</code>)</p>



<a name="220193553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220193553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220193553">(Dec 17 2020 at 00:35)</a>:</h4>
<p>But shouldn't that be opt-in, rather than by default?<br>
I think it makes perfect sense for <code>Cargo.lock</code> to consider all targets fwiw, it's only specifically metadata I'm less sure about.</p>



<a name="220193617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220193617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220193617">(Dec 17 2020 at 00:36)</a>:</h4>
<p>I wonder if one way to get around this would be to allow <code>--filter-platform host</code></p>



<a name="220193650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220193650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220193650">(Dec 17 2020 at 00:36)</a>:</h4>
<p>At least that would make it easier for projects that want metadata just for the actual build graph</p>



<a name="220193844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220193844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220193844">(Dec 17 2020 at 00:39)</a>:</h4>
<p>I feel like I can maybe guess your answer, but how would you feel if setting <code>CARGO_BUILD_TARGET</code> automatically set <code>--filter-platform</code> for <code>cargo metadata</code>? Too magical?</p>



<a name="220193958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220193958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220193958">(Dec 17 2020 at 00:40)</a>:</h4>
<p>Or alternatively some other env var. I'm asking specifically because it would give users a nice way to work around lacking support in intermediate tools (e.g., <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6908">https://github.com/rust-analyzer/rust-analyzer/issues/6908</a>)</p>



<a name="220261280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220261280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220261280">(Dec 17 2020 at 15:56)</a>:</h4>
<p>Unfortunately I think this touches on a number of issues so I don't think there's a clear solution. One issue is the lack of build plans forcing the use of <code>cargo metadata</code>, and another is that <code>cargo metadata</code> explicitly does not have <code>--target</code> since it doesn't mirror the <code>--target</code> of build as that's a layer deeper in cargo, below the abstraction level of <code>cargo metadata</code>. It's been awhile since I brushed up on these issues though.</p>



<a name="220272306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/metadata-target/near/220272306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/metadata-target.html#220272306">(Dec 17 2020 at 17:14)</a>:</h4>
<p>Hmm, interesting. I think then supporting <code>--filter-platform host</code> is probably the way to go. I can add a PR for that pretty easily. I think the PR above makes sense regardless though, as it just fixes a known issue with the current implementation, and does not actually change behavior.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>